#include "lv_weather.h"




void lvgl_window_create(lv_obj_t *parent, char *temp, char *weather)
{
   
    LV_IMG_DECLARE(background);
    // lv_obj_t *label;
    // lv_obj_t *label2;
    /*设置北京色*/
    lv_obj_t * img1 = lv_img_create(parent);
    lv_img_set_src(img1, &background);
    lv_obj_align(img1, LV_ALIGN_CENTER, 0, 0);
    lv_obj_set_size(img1, background.header.w, background.header.h);
    lv_obj_set_size(parent, 320, 240);

    /*设置标签内容*/
    // label = lv_label_create(parent);
    // label2 = lv_label_create(parent);
    // /*设置温度*/
    // lv_label_set_text(label, temp);
    // lv_obj_set_width(label, 150);

    // /*中心对齐*/
    // lv_obj_align(label,LV_ALIGN_CENTER,0,0);
    // lv_label_set_long_mode(label2, LV_LABEL_LONG_SCROLL_CIRCULAR); /*Circular scroll*/
    // lv_obj_set_width(label2, 150);
    // lv_label_set_text(label2, weather);
    // lv_obj_align(label2, LV_ALIGN_CENTER, 0, 40);

    static lv_style_t style;
    lv_style_init(&style);

    lv_style_set_radius(&style, 3);

    lv_style_set_bg_opa(&style, LV_OPA_100);                            /*设置不透明度*/
    lv_style_set_bg_color(&style, lv_palette_main(LV_PALETTE_BLUE));    /*设置背景色*/
    lv_style_set_bg_grad_color(&style, lv_palette_darken(LV_PALETTE_BLUE, 2));
    lv_style_set_bg_grad_dir(&style, LV_GRAD_DIR_VER);

    lv_style_set_border_opa(&style, LV_OPA_40);                         /*设置边界透明度*/
    lv_style_set_border_width(&style, 2);                               /*设置边界宽度*/
    lv_style_set_border_color(&style, lv_palette_main(LV_PALETTE_GREY));/*设置边界颜色*/

    lv_style_set_shadow_width(&style, 8);                               /*设置阴影宽度*/       
    lv_style_set_shadow_color(&style, lv_palette_main(LV_PALETTE_GREY));/*设置阴影颜色*/
 //   lv_style_set_shadow_ofs_y(&style, 8);                             /*设置阴影y偏移*/

    lv_style_set_outline_opa(&style, LV_OPA_COVER);
    lv_style_set_outline_color(&style, lv_palette_main(LV_PALETTE_BLUE));

    lv_style_set_text_color(&style, lv_color_white());
    lv_style_set_pad_all(&style, 10);

    /*Init the pressed style*/
    static lv_style_t style_pr;
    lv_style_init(&style_pr);

    /*Ad a large outline when pressed*/
    lv_style_set_outline_width(&style_pr, 30);
    lv_style_set_outline_opa(&style_pr, LV_OPA_TRANSP);

    lv_style_set_translate_y(&style_pr, 5);
    lv_style_set_shadow_ofs_y(&style_pr, 3);
    lv_style_set_bg_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 2));
    lv_style_set_bg_grad_color(&style_pr, lv_palette_darken(LV_PALETTE_BLUE, 4));

    /*Add a transition to the the outline*/
    static lv_style_transition_dsc_t trans;
    static lv_style_prop_t props[] = {LV_STYLE_OUTLINE_WIDTH, LV_STYLE_OUTLINE_OPA, 0};
    lv_style_transition_dsc_init(&trans, props, lv_anim_path_linear, 300, 0, NULL);

    lv_style_set_transition(&style_pr, &trans);

    lv_obj_t * btn1 = lv_btn_create(parent);
    lv_obj_remove_style_all(btn1);                          /*Remove the style coming from the theme*/
    lv_obj_add_style(btn1, &style, 0);
    lv_obj_add_style(btn1, &style_pr, LV_STATE_PRESSED);
   // lv_obj_set_size(btn1, LV_SIZE_CONTENT, LV_SIZE_CONTENT);    /*根据内容决定大小以及长度*/
    lv_obj_set_size(btn1, 100, 40);    /*根据内容决定大小以及长度*/
    lv_obj_align(btn1, LV_ALIGN_CENTER, 0, -40);

    lv_obj_t * label = lv_label_create(btn1);
    lv_label_set_text(label, weather);
    lv_obj_center(label);

    lv_style_set_transition(&style_pr, &trans);

    lv_obj_t * btn2 = lv_btn_create(parent);
    lv_obj_remove_style_all(btn2);                          /*Remove the style coming from the theme*/
    lv_obj_add_style(btn2, &style, 0);
    lv_obj_add_style(btn2, &style_pr, LV_STATE_PRESSED);
    //lv_obj_set_size(btn2, LV_SIZE_CONTENT, LV_SIZE_CONTENT);    /*根据内容决定*/
    lv_obj_set_size(btn2, 100, 40);    /*根据内容决定*/
    lv_obj_align(btn2, LV_ALIGN_CENTER, 0, 40);
   // lv_obj_center(btn2);

    lv_obj_t * label2 = lv_label_create(btn2);
    lv_label_set_text(label2, temp);
    lv_obj_center(label2);

}
